<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/3/15 0015
 * Time: 下午 3:53
 */

namespace app\admin\controller;


use app\admin\model\VideoCate;
use think\Controller;
use think\Request;

class Video extends Controller
{
    public function videoData()
    {
        $video=new \app\admin\model\videoList();
        $video_info=$video->info();
        return json_encode($video_info);
    }

    public function videoUpdate($id)
    {
        $video=new \app\admin\model\videoList();
        $video_info=$video->getInfo($id);
        return json_encode($video_info);
    }

    /**
     * @return \think\response\View
     */
    public function videoList(){
        $video=new \app\admin\model\videoList();
        $video_info=$video->info();
        $this->assign(['video_info'=>$video_info]);
        return view('videoList');
    }

    public function videoInfo(){

    }

    public function videoAddEdit(){
        if ($type = Request::instance()->param('type') == 'edit'){
            $info = \app\admin\model\Video::get(Request::instance()->param('vid'));
            $this->assign("video_info",$info);
        }
        $videoCate = new VideoCate();
        $cates = $videoCate::all();
        $this->assign("cates",$cates);
        return view();
    }

    public function videoOper(){
        if (Request::instance()->post()){//增删改
            switch ($type = Request::instance()->post('type')){
                case "add":
                    break;
                case "edit":
                    break;
                case "del":
                    break;
                default:
                    $this->error("操作错误",url("video/videoList"));
                    break;
            }
        }else{//查
            $id = Request::instance()->post('id');
            $video = model('hy_video_list');
            $this->assign("video",$video::get($id));
            return view('video/videoinfo');
        }
    }
}